|
|
|
|
|
|
|
As you can see in this code, youre returning a value that represents which quarter youre in. The total size of the string is five characters. This is why you set the Size argument in the FormatSize event to 5. |
|
|
|
|
|
|
|
|
The CallBackKeyDown Event |
|
|
|
|
|
|
|
|
Besides these two events that are called when you have a custom format defined with the X character, another event is also firedCallBackKeyDown. This event is fired whenever a key is pressed when the DateTimePicker control has focus and has a CustomFormat property with the X format character in it. You can use this event to respond to user keystrokes. In the following code, youll see an example that allows the user to press the letter J to toggle between January, June, and July without having to bring up the calendar and jump to those months: |
|
|
|
 |
|
|
|
|
Private Sub DTPicker7_CallbackKeyDown(_
ByVal KeyCode As Integer, _
ByVal Shift As Integer, _
ByVal CallbackField As String, _
CallbackDate As Date)
Dim strDayYear As String
strDayYear = DTPicker7.Day & "/" & DTPicker7.Year
Select Case UCase$(Chr(KeyCode))
Case "J"
If Month(DTPicker7.Value) = 1 Then CallbackDate = CDate("06/" & strDayYear) ElseIf Month(DTPicker7.Value) = 6 Then
CallbackDate = CDate("07/" & strDayYear)
Else
CallbackDate = CDate("01/" & strDayYear)
End If
Case "F"
CallbackDate = CDate("02/" & strDayYear)
Case "M"
If Month(DTPicker7.Value) = 3 Then
CallbackDate = CDate("05/" & strDayYear)
Else
CallbackDate = CDate("03/" & strDayYear)
End If
Case "A" |
|
|
|
|
|